#ifndef _VARIABLE_H
#define _VARIABLE_H

#include <stdint.h>
#define MEMORY_SIZE (4*1024)

extern uint8_t amemory[MEMORY_SIZE];

typedef enum{
	VAR_NUMBER_NONE = 0,
	VAR_NUMBER_UINT8 = 1,
	VAR_NUMBER_INT8 = 2,
	VAR_NUMBER_UINT16 = 3,
	VAR_NUMBER_INT16 = 4,
	VAR_NUMBER_UINT32 = 5,
	VAR_NUMBER_INT32 = 6,
	VAR_NUMBER_UINT64 = 7,
	VAR_NUMBER_INT64 = 8
}variable_type_t;

typedef enum{
	LIQUID_DEFAULT = 10,//32bit
	LIQUID_ACCUM = 14,//32bit
	PRESSURE_UNIT = 18,//8bit
	TREAT_MODE = 19,//8bit
	SPEED = 20,//32bit
	INJECTOR_TYPE=24,//8bit 注射器类型
	
}save_param_enum;

typedef enum{
	TREAT_ANIMATION1=2048,//8bit 主页面圆动画
	TREAT_ANIMATION2=2049,//8bit 主页面圆动画
	TREAT_ANIMATION3=2050,//8bit 主页面圆动画

	TIME_REMAIN_1=2051,//32bit
	TIME_REMAIN_2=2055,//32bit
	TIME_REMAIN_3=2059,//32bit
	TREAT_SPEED = 2063,//32bit
}nosave_param_enum;

typedef struct{
	uint16_t liquid_default;// 10, 预置液量
	uint16_t liquid_accumulate;//12 累积液量
}param_str;


typedef struct{
	uint16_t addr;
	uint16_t type;
	uint16_t ratio;
	uint16_t point;
}variable_t;

#define _var_uint8(addr) *((uint8_t *)(amemory + addr))
#define _var_int8(addr) *((int8_t *)(amemory + addr))

#define _var_uint16(addr) *((uint16_t *)(amemory + addr))
#define _var_int16(addr) *((int16_t *)(amemory + addr))

#define _var_uint32(addr) *((uint32_t *)(amemory + addr))
#define _var_int32(addr) *((int32_t *)(amemory + addr))

#define _set_uint8(addr,val) *((uint8_t *)(amemory + addr)) = val
#define _get_uint8(addr) *((uint8_t *)(amemory + addr))

#define _set_int8(addr,val) *((int8_t *)(amemory + addr)) = val
#define _get_int8(addr) *((int8_t *)(amemory + addr))

#define _set_uint16(addr,val) *((uint16_t *)(amemory + addr)) = val
#define _get_uint16(addr) *((uint16_t *)(amemory + addr))

#define _set_int16(addr,val) *((int16_t *)(amemory + addr)) = val
#define _get_int16(addr) *((int16_t *)(amemory + addr))

#define _set_uint32(addr,val) *((uint32_t *)(amemory + addr)) = val
#define _get_uint32(addr) *((uint32_t *)(amemory + addr))

#define _set_int32(addr,val) *((int32_t *)(amemory + addr)) = val
#define _get_int32(addr) *((int32_t *)(amemory + addr))

uint8_t set_uint8(uint16_t addr,uint8_t val);
uint8_t get_uint8(uint16_t addr);

uint8_t set_int8(uint16_t addr,int8_t val);
int8_t get_int8(uint16_t addr);

uint8_t set_uint16(uint16_t addr,uint16_t val);
uint16_t get_uint16(uint16_t addr);

uint8_t set_int16(uint16_t addr,int16_t val);
int16_t get_int16(uint16_t addr);

uint8_t set_uint32(uint16_t addr,uint32_t val);
uint32_t get_uint32(uint16_t addr);

uint8_t set_int32(uint16_t addr,int32_t val);
int32_t get_int32(uint16_t addr);

//uint8_t set_float(uint16_t addr,float val);
//float get_float(uint16_t addr);

uint8_t set_uint64(uint16_t addr,uint64_t val);
uint64_t get_uint64(uint16_t addr);

uint8_t set_int64(uint16_t addr,int64_t val);
int64_t get_int64(uint16_t addr);

uint8_t set_type(variable_t *tmp,char *string);
uint8_t get_number(variable_t *tmp,uint32_t *value);
#endif

